// 创建XMLHttpRequest对象
			function createXMLHttpRequest() {
				let xmlHttpRequest;
				if (window.XMLHttpRequest) {
					xmlHttpRequest = new XMLHttpRequest();
				} else {
					xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
				}
				return xmlHttpRequest;
			}

			// AJAX请求函数
			function ajax(option) {
				//1.创建对象
				let httpRequest = createXMLHttpRequest();
				if (!option.method) {
					//设置默认请求方式为 GET
					option.method = "GET";
				}
				if (!option.async) {
					option.async = true;
				}

				//2.建立请求
				httpRequest.open(option.method, option.url, option.async);

				// 设置请求头
				if (option.headers) {
					for (const [key, value] of Object.entries(option.headers)) {
						httpRequest.setRequestHeader(key, value);
					}
				} else if (option.method == 'POST') {
					httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				}

				//3.设置请求参数
				httpRequest.send(option.params);

				//4.获取响应数据
				httpRequest.onreadystatechange = function() {
					if (httpRequest.readyState == 4) {
						if (httpRequest.status == 200) {
							let data = null;
							if (option.type && option.type.toUpperCase() == "JSON") {
								try {
									data = JSON.parse(httpRequest.responseText);
								} catch (e) {
									if (option.fail) option.fail("解析JSON失败");
									return;
								}
							} else if (option.type === 'XML') {
								data = httpRequest.responseXML;
							} else {
								data = httpRequest.responseText;
							}
							if (option.callback) option.callback(data);
						} else {
							if (option.fail) option.fail("请求失败，状态码: " + httpRequest.status);
						}
					}
				}
			}